/* GUI CONVERTED from rcsqdel.p (converter v1.75) Mon Nov 20 16:58:18 2000 */
/* rcsqdel.p - SEQUENCE SCHEDULE ARCHIVE/DELETE PROGRAM                 */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*V8:ConvertMode=FullGUIReport                                          */
/* REVISION: 9.1   CREATED       : 10/12/99     BY: *N003* Steve Nugent */
/* REVISION: 9.1   LAST MODIFIED : 03/24/00     BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1   LAST MODIFIED : 08/23/00     BY: *N0ND* Mark Brown       */
/* REVISION: 9.1   LAST MODIFIED : 09/06/00     BY: *N0RG* Mudit Mehta      */

/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */
/*         THIS PROGRAM IS A BOLT-ON TO STANDARD PRODUCT MFG/PRO.           */
/* ANY CHANGES TO THIS PROGRAM MUST BE PLACED ON A SEPARATE ECO THAN        */
/* STANDARD PRODUCT CHANGES.  FAILURE TO DO THIS CAUSES THE BOLT-ON CODE TO */
/* BE COMBINED WITH STANDARD PRODUCT AND RESULTS IN PATCH DELIVERY FAILURES.*/
/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */

/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

          {mfdeclre.i}
          {gplabel.i} /* EXTERNAL LABEL INCLUDE */

 /* ********** Begin Translatable Strings Definitions ********** */

&SCOPED-DEFINE rcsqdel_p_3 "Customer Job!Customer Sequence"
/* MaxLen:30 Comment: */

/*N0RG*
 * &SCOPED-DEFINE rcsqdel_p_1 " Customer Sequenced Schedule "
 * /* MaxLen:35 Comment: */
 *
 * &SCOPED-DEFINE rcsqdel_p_2 " Required Quantities "
 * /* MaxLen:25 Comment: */
 *
 * &SCOPED-DEFINE rcsqdel_p_4 "Schedule Detail Data"
 * /* MaxLen:25 Comment: */
 *
 *N0RG*/

 /* ********** End Translatable Strings Definitions ********** */

          define input parameter scx_recid as recid no-undo.
          define input parameter sod_recid as recid no-undo.
          define input parameter detail_only like mfc_logical no-undo.
          define input parameter inactive_only like mfc_logical no-undo.
          define input parameter s_delete like mfc_logical no-undo.
          define input parameter archive like mfc_logical no-undo.

          define shared stream history.
          define variable l_desc1 like pt_desc1 no-undo.

          FORM /*GUI*/ 
            {rcordfma.i}
                  skip(.4)    
            sch_rlse_id colon 46
                  skip(.4)    
            with STREAM-IO /*GUI*/  frame prm side-labels width 80 attr-space
            /*V8+*/
            .

            /* SET EXTERNAL LABELS */
            setFrameLabels(frame prm:handle).

          FORM /*GUI*/ 
            rcsd_date
            rcsd_time
            rcsd_cust_job column-label {&rcsqdel_p_3}
            rcsd_discr_qty
            rcsd_status
            with STREAM-IO /*GUI*/  frame seq2_data down attr-space
            width 80 title color normal
            (getFrameTitle("SCHEDULE_DETAIL_DATA",26)).

            /* SET EXTERNAL LABELS */
            setFrameLabels(frame seq2_data:handle).

          for first scx_ref where recid(scx_ref) = scx_recid no-lock:
          end.

          for first sod_det where recid(sod_det) = sod_recid no-lock:
          end.

          for each rcs_mstr where
                   rcs_shipfrom = scx_shipfrom and
                   rcs_shipto   = scx_shipto exclusive-lock:

                   if rcs_active and inactive_only then next.

                   for each rcsd_det where
                            rcsd_shipfrom = rcs_shipfrom and
                            rcsd_shipto   = rcs_shipto   and
                            rcsd_rlse_id  = rcs_rlse_id  and
                            rcsd_order    = scx_order    and
                            rcsd_line     = scx_line     and
                            rcsd_cust_po  = scx_po exclusive-lock
                            break
                               by rcsd_rlse_id
                               by rcsd_date
                               by rcsd_time
                               by rcsd_cust_job:

                            if first-of(rcsd_rlse_id) then do:
                               for first ad_mstr where
                                         ad_addr = scx_shipto no-lock:
                               end.
                               for first pt_mstr where
                                         pt_part = scx_part no-lock:
                               end.
                               if available pt_mstr then
                                  l_desc1 = pt_desc1.
                               else
                                  l_desc1 = "".

                               display
                                  scx_shipfrom
                                  scx_shipto
                                  ad_name       when (available ad_mstr)
                                  scx_part
                                  l_desc1       @ sod_desc
                                  sod_custpart  when (available sod_det)
                                  pt_um         when (available pt_mstr)
                                  scx_po
                                  rcs_rlse_id   @ sch_rlse_id
                                  scx_order
                                  scx_line
                                  with frame prm STREAM-IO /*GUI*/ .

                             do with frame seq1_data:
                   /* SET EXTERNAL LABELS */
                               setFrameLabels(frame seq1_data:handle).
                               display
                                  rcs_date_type    colon 20
                                  rcs_cr_date      colon 55
                                  rcs_cr_time      no-label
                                  rcs_active_start colon 20
                                  rcs_cumulative   colon 55
                                  rcs_active_end   colon 20
                                  with frame seq1_data attr-space side-labels
                                  width 80 STREAM-IO /*GUI*/ .
                             end. /* do with */
                end.

                            if first-of(rcsd_date) or
                               first-of(rcsd_time) or
                               first-of(rcsd_cust_job) then do:

                               display
                                 rcsd_date
                                 rcsd_time
                                 rcsd_cust_job
                                 rcsd_status
                                 with frame seq2_data STREAM-IO /*GUI*/ .
                            end.

                            down 1 with frame seq2_data.

                            display
                                 rcsd_cust_seq @ rcsd_cust_job
                                 rcsd_discr_qty
                                 with frame seq2_data STREAM-IO /*GUI*/ .

                            down 1 with frame seq2_data.

                            for each rcsx_ref where
                                rcsx_rlse_id = rcsd_rlse_id exclusive-lock:

                                if s_delete then do:

                                   if archive then do:
                                      export stream history "rcsx_ref".
                                      export stream history rcsx_ref.
                                   end.

                                   delete rcsx_ref.
                                end.
                            end.

                            if s_delete then do:

                               if archive then do:
                                  export stream history "rcsd_det".
                                  export stream history rcsd_det.
                               end.

                               delete rcsd_det.
                            end.

                            if not can-find (first rcsd_det where
                                   rcsd_shipfrom = rcs_shipfrom and
                                   rcsd_shipto   = rcs_shipto) and
                                   not detail_only then do:

                                   if archive and not detail_only then do:
                                      export stream history "rcs_mstr".
                                      export stream history rcs_mstr.
                                   end.

                                   delete rcs_mstr.
                            end.
                end. /* for each rcsd_det */
            end. /* for each rcs_mstr */
